package com.zh.work.service.platform.channel.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zh.work.dao.platform.channel.OnlineChannelMerchMapper;
import com.zh.work.entity.channel.OnlineChannelMerchEntity;
import com.zh.work.service.platform.channel.OnlineChannelMerchService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * code is far away from bug with the animal protecting
 * ┏┓　　　┏┓
 * ┏┛┻━━━┛┻┓
 * ┃　　　　　　　┃
 * ┃　　　━　　　┃
 * ┃　┳┛　┗┳　┃
 * ┃　　　　　　　┃
 * ┃　　　┻　　　┃
 * ┃　　　　　　　┃
 * ┗━┓　　　┏━┛
 * 　　┃　　　┃神兽保佑
 * 　　┃　　　┃代码无BUG！
 * 　　┃　　　┗━━━┓
 * 　　┃　　　　　　　┣┓
 * 　　┃　　　　　　　┏┛
 * 　　┗┓┓┏━┳┓┏┛
 * 　　　┃┫┫　┃┫┫
 * 　　　┗┻┛　┗┻┛
 *
 * @Description: 网关商户设置业务逻辑实现层
 * @Author: Li.HuiNeng
 * @Create in: 2019/09/05
 * @Version: 1.0.1
 */
@Service
public class OnlineChannelMerchServiceImpl extends ServiceImpl<OnlineChannelMerchMapper, OnlineChannelMerchEntity> implements OnlineChannelMerchService {

    @Autowired
    private OnlineChannelMerchMapper mapper;


    @Override
    public IPage<OnlineChannelMerchEntity> selectOnlineChannelMerchPages(Page<OnlineChannelMerchEntity> page, OnlineChannelMerchEntity onlineChannelMerchEntity) {
        return this.mapper.selectPage(
                page,
                new LambdaQueryWrapper<OnlineChannelMerchEntity>()
                        .select(OnlineChannelMerchEntity::getChannelCode,OnlineChannelMerchEntity::getBranchNo,OnlineChannelMerchEntity::getMerchNo,
                                OnlineChannelMerchEntity::getMerchName,OnlineChannelMerchEntity::getTermNo,OnlineChannelMerchEntity::getKeyMd5,
                                OnlineChannelMerchEntity::getStatus,OnlineChannelMerchEntity::getMaxTrans,OnlineChannelMerchEntity::getTodayTrans,
                                OnlineChannelMerchEntity::getKeyRsa,OnlineChannelMerchEntity::getId)
                        .eq(StringUtils.isNotEmpty(onlineChannelMerchEntity.getChannelCode()), OnlineChannelMerchEntity::getChannelCode, onlineChannelMerchEntity.getChannelCode())
                        .eq(StringUtils.isNotEmpty(onlineChannelMerchEntity.getBranchNo()), OnlineChannelMerchEntity::getBranchNo, onlineChannelMerchEntity.getBranchNo())
                        .like(StringUtils.isNotEmpty(onlineChannelMerchEntity.getMerchNo()), OnlineChannelMerchEntity::getMerchNo, onlineChannelMerchEntity.getMerchNo())
                        .like(StringUtils.isNotEmpty(onlineChannelMerchEntity.getTermNo()), OnlineChannelMerchEntity::getTermNo, onlineChannelMerchEntity.getTermNo())
        );
    }

}
